{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# 作业1：问卷+环境配置+大语言模型部署"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 0. 说明"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 0.1 关于 Jupyter Notebook"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Jupyter Notebook 是一种可编程的文档类型，类似于 R Markdown。Jupyter Notebook 文档以一个个单元格组成，每个单元格可以是 Markdown 或者 Python 代码：前者通常用来写文字说明，后者用来运行代码。比如你双击第一行的标题，就会看到标题的 Markdown 代码（以 `#` 符号开头），再按 `Ctrl+Enter`，就会显示 Markdown 渲染的结果。"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "而对于代码单元格， `Ctrl+Enter` 会执行单元格内的代码，例如用鼠标点击下面的单元格然后按键后会出现形如 `Out[x]` 的输出结果。"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "3.141592653589793"
      ]
     },
     "execution_count": 1,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "import math\n",
    "\n",
    "math.pi\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "我们的作业中既有需要说明的文字，又有需要编写的程序，前者用 Markdown 单元格，后者用代码单元格。单元格的类型可以在上方的下拉菜单中选择，也可以通过快捷键实现（通过菜单 Cell => Cell Type 查看）。"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 0.2 关于 Markdown"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Markdown 是常用的文档格式化语法，如果有不熟悉的，可以参考[这里](https://www.jianshu.com/p/335db5716248)的教程。需要说明的是 Jupyter Notebook 里可以插入数学公式，例如 $f(x)=\\frac{1}{\\sqrt{2\\pi}}e^{-x^2/2}$。双击这个单元格来查看源代码。"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 1. 问卷"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "思考并回答**至少四个**问题："
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "- 你现在对深度学习有多少了解？"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "深度学习是机器学习的一个子领域，它基于人工神经网络的学习算法，特别是那些具有多层（深层）结构的网络。深度学习模型能够学习数据的多层次表示和抽象，这使得它们在许多任务中表现出色，包括图像和语音识别、自然语言处理、医学图像分析、药物发现、自动驾驶汽车等。"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "- 你预期今后的工作/研究与深度学习的关联大吗？"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "有关联，目前暑期实习在腾讯的智慧出行部门，需要了解一些自动驾驶相关的模型。"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "- 你想从这门课学到什么？"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "深度学习的框架，以及如何学习，很难要求老师这么短时间教会我们太多，但是希望能有一个大的框架方便提纲挈领。"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "- 你还有哪些喜欢的获取知识的渠道（例如B站，知乎，技术博客，公众号等）？如果有请向大家推荐一些，**具体到账号或网址**，不需要与深度学习相关。"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "CSDN/简书网/即刻/哔哩哔哩 \n",
    "哔哩哔哩：https://space.bilibili.com/287822013?spm_id_from=333.337.search-card.all.click   有一次忽然发现杜比声效/dolby audio，便去b站找杜比\n",
    "    的介绍，于是发现一个介绍空调参数的up主，讲的深入浅出。\n",
    "哔哩哔哩：https://space.bilibili.com/12119849/?spm_id_from=333.999.0.0   红星小学中队长 \n",
    "    最近由于家里在装修，便突发奇想对各种家居博主很好奇，于是发现一个直男up主，追求性价比的智能家居，还有在他家楼下安装充电桩，蛮有意思的。\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "- 你对编程的喜欢/厌恶程度是多少？1为很厌恶，10为很喜欢。"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "5"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "- 你喜欢/**不**喜欢的上课方式是怎样的？"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "喜欢的方式：老师上课以启发性思考为主，不设定具体学习范围，canvas会附上很多参考论文/网站，允许自由探索\n",
    "不喜欢的方式：照本宣科，读PPT，死记硬背"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 2. 安装 PyTorch"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "请参照课程文档《PyTorch安装》的提示配置好 PyTorch 环境。如果你的电脑具备 Nvidia 显卡，优先尝试安装 GPU 版本。用如下的代码验证 Conda 和 PyTorch 安装是否成功："
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\n",
      "     active environment : base\n",
      "    active env location : D:\\anaconda\n",
      "            shell level : 1\n",
      "       user config file : C:\\Users\\86187\\.condarc\n",
      " populated config files : C:\\Users\\86187\\.condarc\n",
      "          conda version : 23.7.4\n",
      "    conda-build version : 3.26.0\n",
      "         python version : 3.11.4.final.0\n",
      "       virtual packages : __archspec=1=x86_64\n",
      "                          __cuda=11.1=0\n",
      "                          __win=0=0\n",
      "       base environment : D:\\anaconda  (writable)\n",
      "      conda av data dir : D:\\anaconda\\etc\\conda\n",
      "  conda av metadata url : None\n",
      "           channel URLs : https://mirrors.sjtug.sjtu.edu.cn/anaconda/pkgs/main/win-64\n",
      "                          https://mirrors.sjtug.sjtu.edu.cn/anaconda/pkgs/main/noarch\n",
      "                          https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/pytorch/win-64\n",
      "                          https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/pytorch/noarch\n",
      "                          https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/win-64\n",
      "                          https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/noarch\n",
      "                          https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/win-64\n",
      "                          https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/noarch\n",
      "                          https://repo.anaconda.com/pkgs/main/win-64\n",
      "                          https://repo.anaconda.com/pkgs/main/noarch\n",
      "                          https://repo.anaconda.com/pkgs/r/win-64\n",
      "                          https://repo.anaconda.com/pkgs/r/noarch\n",
      "                          https://repo.anaconda.com/pkgs/msys2/win-64\n",
      "                          https://repo.anaconda.com/pkgs/msys2/noarch\n",
      "          package cache : D:\\anaconda\\pkgs\n",
      "                          C:\\Users\\86187\\.conda\\pkgs\n",
      "                          C:\\Users\\86187\\AppData\\Local\\conda\\conda\\pkgs\n",
      "       envs directories : D:\\anaconda\\envs\n",
      "                          C:\\Users\\86187\\.conda\\envs\n",
      "                          C:\\Users\\86187\\AppData\\Local\\conda\\conda\\envs\n",
      "               platform : win-64\n",
      "             user-agent : conda/23.7.4 requests/2.31.0 CPython/3.11.4 Windows/10 Windows/10.0.22631 aau/0.4.1 c/eBFvT5jTCaPUZa8R0Ae0vQ s/qjFxC5tsO3uLIa58xQ_AQQ e/-IFCJgIutETMeqcMjsxjhg\n",
      "          administrator : False\n",
      "             netrc file : None\n",
      "           offline mode : False\n",
      "\n",
      "\n"
     ]
    }
   ],
   "source": [
    "!conda info"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "tensor([[-0.1115,  0.1204, -0.3696],\n",
       "        [-0.2404, -1.1969,  0.2093],\n",
       "        [-0.9724, -0.7550,  0.3239],\n",
       "        [-0.1085,  0.2103, -0.3908],\n",
       "        [ 0.2350,  0.6653,  0.3528]])"
      ]
     },
     "execution_count": 1,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "import torch\n",
    "torch.manual_seed(123)\n",
    "torch.randn(5, 3)\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {
    "scrolled": true
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "True"
      ]
     },
     "execution_count": 2,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "torch.cuda.is_available()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 3. 部署大语言模型"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "1. 前往 https://cloud.perfxlab.cn/ 注册一个账号；\n",
    "2. 访问 [https://cloud.perfxlab.cn/panel/team_invite?inviteCode=twfRKQkySvBmrV00](https://cloud.perfxlab.cn/panel/team_invite?inviteCode=twfRKQkySvBmrV00)，将上一步中注册的账号添加进课程组；\n",
    "3. 观看视频 [https://www.bilibili.com/video/BV1an4y1o7iS](https://www.bilibili.com/video/BV1an4y1o7iS)，并学习其中的步骤，在自己的电脑上搭建一个聊天机器人；\n",
    "4. 作业中需要对模型进行一定程度的定制，比如聊天机器人的自我认知应该是你的学习助手，下面的聊天记录截图中也要**体现出和你有关的信息**；\n",
    "5. 与聊天机器人进行一些互动，并将截图插入本 Notebook 中（使用 Markdown 语法插入图片，图片需要与 Notebook 文件一同上传 Gitee）。"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "注意：\n",
    "1. 视频中的内容可能会因为软件版本更新等情况与实际的部署过程产生一些差异，请灵活根据实际情况寻找解决方案，不要生搬硬套；\n",
    "2. 如果遇到问题，尽可能利用网络资源寻找可能的解决方案（在今后的工作和学习中，几乎很少有手把手教你操作且100%成功的教程，这是锻炼实际解决问题能力的过程中必要的一环）；\n",
    "3. 视频中使用了 Llama 作为聊天机器人的基座模型，作业中请在如下范围内选择（可在 PerfXCloud 的“模型广场”页面中查看模型介绍）：\n",
    "   - Qwen2-7B-Instruct\n",
    "   - MindChat-Qwen-7B-v2\n",
    "   - Yi-Coder-1.5B-Chat\n",
    "   - Yi-Coder-9B-Chat\n",
    "   - Yi-1_5-9B-Chat-16K\n",
    "   - deepseek-v2-lite-chat\n",
    "   - chatglm3-6b"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "你的 PerfXCloud 账号是："
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "\n",
    "perfxcloud_18713367869"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "请插入你和聊天机器人互动的截图，注意要体现定制化的结果。Markdown 语法：`![](image.jpg)`，图片文件需一同上传 Gitee。"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "<请插入截图>"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.11.4"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 4
}
